-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emphasizing Error-Inducing Code Chunks for Text-Based Reporters #970
Merged
david-yz-liu
merged 15 commits into
pyta-uoft:master
from
umututku03:reporter_colouring
Oct 17, 2023
Merged
Emphasizing Error-Inducing Code Chunks for Text-Based Reporters #970
david-yz-liu
merged 15 commits into
pyta-uoft:master
from
umututku03:reporter_colouring
Oct 17, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pull Request Test Coverage Report for Build 6539593624
💛 - Coveralls |
david-yz-liu
reviewed
Oct 8, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@umututku03 this is a great start. Some overall comments:
- Make sure to update the changelog (add this entry as an "enhancement").
- Right now the
PlainReporter._add_line
method is duplicating a substantial amount of code from the superclass_add_line
method. The right way to think about this method is that it should first call the superclass method (to build an initial snippet), and then add an additional line of text after that snippet that contains the underlining characters. - As a related point, right now you're using
len(snippet)
(and similar other code) to determine the amount of "pre-space" to use. Rather than doing that, you should calculate more precisely exactly how much space to be added without relying on the snippet at all! The implementation of_add_line_number
gives you a starting point, as does theslice_.start
value. - I suspect if you make the change from (3), it will also fix the issue you're seeing with the
ColorReporter
. While you are correct that dependency injection and an intermediate layer "text reporter" parent class would be possible (with subclasses filling in the "underlining" functionality), in this case I suspect there's a simpler approach involving updating thePlainReporter._add_line
method.
… into reporter_colouring
@umututku03 great, please also do a merge from |
for more information, see https://pre-commit.ci
… into reporter_colouring
david-yz-liu
approved these changes
Oct 17, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
PythonTA currently supports various types of reporters, including
HTMLReporter
(which generates an HTML file) and text-based reporters likePlainReporter
andColourReporter
. The HTML-based reporter effectively highlights the sections that cause errors. However, there's an issue with thePlainReporter
. It generates a.txt
file without any highlighting, making it difficult to distinguish between the code with errors and other content. Additionally,ColourReporter
inherits fromPlainReporter
, necessitating adjustments to maintain its existing functionality while addressing this highlighting concern.Your Changes
Description:
I've overridden the
PlainReporter._add_line
method to incorporate an over-line character (Unicode 203E) beneath any section highlighted as an error. Additionally, I've overridden theColourReporter._add_line
method to ensure it inherits the functionality ofPythonTaReporter._add_line
. This change allows us to maintain the existing behavior ofColourReporter
while addressing the required enhancements (notice thatPlainReporter
is the parent class ofColourReporter
).Type of change (select all that apply):
Testing
I did a lot of manual testings for this change. Below, I've included several screenshots showcasing the modifications I've implemented, along with corresponding comparisons across various types of reporters.
ColourReporter
PlainReporter
HTMLReporter
More examples
Questions and Comments (if applicable)
Is it advisable to introduce an abstraction layer for text-based reporters? Considering the SOLID Principles we're currently studying in CSC207, it appears to align with the Dependency Inversion Principle. Would this interpretation accurately apply to our subject?
Checklist